import myaxios from '../Myaxios'
import BASEURL from '../BaseUrl'
const { BMDURL } = BASEURL
const commidityApi = {
    /**
     * 通过id查询商品信息
     * @param {Object} params 
     * @returns 
     */
    queryById(params) {
        return myaxios.get(BMDURL + '/commodity/details', params)
    },
    /**
     * 分页查询所有商品列表
     * @param {object} params 
     * @returns 
     */
    queryAll(params) {
        return myaxios.get(BMDURL + '/commodity/list', params)
    },
    /**
    * 根据商品类别查询列表
    * @param {Object} params 
    * @returns 
    */
    queryByType(params) {
        return myaxios.get(BMDURL + '/commodity/list/classify', params)
    },
    /**
    * 根据商品名称查询商品列表
    * @param {Object} params 
    * @returns 
    */
    queryByTitle(params) {
        return myaxios.get(BMDURL + '/commodity/search', params)
    },
    /**
   * 添加商品
   * @param {Object} params 
   * @returns 
   */
    add(params) {
        return myaxios.post('http://localhost:9000' + '/upload', params)
    },
    /**
    * 通过id删除商品
    * @param {Object} params 
    * @returns 
    */
    delete(params) {
        return myaxios.post(BMDURL + '/commodity/delete', params)
    },
    /**
   * 修改商品
   * @param {Object} params 
   * @returns 
   */
    update(params) {
        return myaxios.post(BMDURL + '/commodity/modify', params)
    },
    /**
  * 是否上下架
  * @param {Object} params 
  * @returns 
  */
    shelves(params) {
        return myaxios.post(BMDURL + '/commodity/shelves', params)
    },
}
export default commidityApi